//
//  FlacFuseAudioObject.h
//  FlacFuse
//
//  Created by Fabián Cañas on 9/13/10.
//  Copyright (c) 2010 University of Colorado, Boulder. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "FLAC/all.h"

@interface FlacFuseAudioObject : NSObject {
@private
    BOOL isFinishedTranscoding;
    NSString *sourcePath;
    NSDate  *lastAccess;
    NSDictionary *fileProperties;
    
    NSString *dataFileLocation;
    FILE *dataFile;
    int fildes;
    
    FLAC__StreamDecoder *streamDecoder;
    FLAC__uint64 total_samples;
    unsigned sample_rate;
    unsigned channels;
    unsigned bps;
}

// What's up with this Object? (Pretty high-level stuff)
@property (readwrite) BOOL isFinishedTranscoding;
@property (readwrite, nonatomic, retain) NSString *sourcePath;
@property (readwrite, nonatomic, retain) NSDate *lastAccess;
@property (readwrite, nonatomic, retain) NSDictionary *fileProperties;

// Temporary file (Lower level)
@property (readwrite, retain, nonatomic) NSString *dataFileLocation;
@property (readwrite, nonatomic) FILE *dataFile;
@property (readwrite, nonatomic) int fildes;

// FLAC-specific properties (Lowest level)
@property (readwrite, nonatomic) FLAC__StreamDecoder *streamDecoder;
@property (readwrite, nonatomic) FLAC__uint64 total_samples;
@property (readwrite, nonatomic) unsigned sample_rate;
@property (readwrite, nonatomic) unsigned channels;
@property (readwrite, nonatomic) unsigned bps;

-(int) readToBuffer:(char *)buffer size:(size_t)size offset:(off_t)offset error:(NSError **)error;

-(id) initWithSourcePath:(NSString *)path;

-(BOOL) open;

-(int) readToBuffer:(char *)buffer size:(size_t)size offset:(off_t)offset error:(NSError **)error;

-(int) writeFromBuffer:(char *)buffer size:(size_t)size offset:(off_t)offset error:(NSError **)error;

-(void) close;

@end
